package demo.practice.dp;

public class P300 {

    public static void main(String[] args) {
        P300 p300 = new P300();
        p300.lengthOfLIS(new int[]{10, 9, 2, 5, 3, 7, 101, 18});
    }

    public int lengthOfLIS(int[] nums) {
        if (nums == null || nums.length == 0)
            return -1;
        int[] dp = new int[nums.length];
        // for (int i = 0; i < dp.length; i++) {
        //     dp[i] = 1;
        // }
        int max = 1;
        dp[0] = 1;
        for (int i = 1; i < nums.length; i++) {
            //int thisdpi=dp[i];
            dp[i] = 1;
            for (int j = 0; j < i; j++) {
                if (nums[i] > nums[j]) {//单调增的
                    dp[i] = Math.max(dp[j] + 1, dp[i]);
                }
            }
            max = Math.max(max, dp[i]);
        }
        return max;
    }


}
